///////////////////////////////////////////////////////////////
// Copyright(c) ephiroth
// 
// FileName : formula_recursion.c
// Creator  : ephiroth
// E-Mail   : ephiroth@gmail.com
// Date     : 2009-04-03
// Comment  : 
//
///////////////////////////////////////////////////////////////
#include "comm.h"

static int func_recursion (int index, U8  * data)
{
	int ret = 0 ;
	_DEBUG_("DATA-6=%d\n",data[MAX_DATA_LENGTH-6]);
	U8 flag = trim_char(data[MAX_DATA_LENGTH-6],2,4);
	U8 begin_index = index - flag;
	int i;
	if (index < flag)
		return trim_char(data[index],1,99);
	for (i= begin_index;i<index;i++ )
		ret = ret + func_recursion(i,data);
	return ret;

}


static void help_recursion ( U8 * data )
{
	U8 flag = trim_char(data[MAX_DATA_LENGTH-6],2,4);
	printf ("[前%d个数之和]\n",flag);
}


formula formula_recursion = {
	"recursion",
	ft_normal,
	7,
	func_recursion,
	help_recursion,
};

